const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require("path")
const webpack = require("webpack")
const VueLoaderPlugin =  require('vue-loader/lib/plugin')

module.exports = {
    // context: path.resolve(__dirname, '/'),
    entry: './index.js',
    output: {
        path: __dirname + '/dist',
        publicPath: '/',
        filename: 'mutifork-tree.min.js',
        libraryTarget: 'umd',
        umdNamedDefine: true
    },
    resolve:{
        alias:{
            'vue$':'vue/dist/vue.js'
        }
    },
    module: {
        rules: [
            {
                test: /\.vue$/,
                loader: 'vue-loader',
                options: {
                    cssModules: {
                      localIdentName: '[path][name]---[local]---[hash:base64:5]',
                      camelCase: true
                    }
                  }
            },
            {
                test: /\.styl(us)?$/,
                use: [
                    'vue-style-loader',
                    'css-loader',
                    'stylus-loader'
                ]
            },
            {
                test: /\.js$/,
                loader: 'babel-loader',
            },
            {
                test: /\.(png|jpg|gif|ttf|svg|woff|eot)$/,
                loader: 'url-loader',
                query: {
                    limit: 30000,
                    name: '[name].[ext]?[hash]'
                }
            }
        ]
    },
    mode: 'development',
    devServer: {
        //其他配置
        // contentBase: path.join(__dirname, '/'),
        compress: true,
        port: 9000
    },
    plugins: [
        new HtmlWebpackPlugin({
            filename: 'index.html',
            template: 'index.html',
            inject: true
        }),
        new VueLoaderPlugin()
    ]
}

// module.exports = config;